package com.toby.ioc.imports;

import com.toby.ioc.component.TobyBean;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @desc:
 * @author: toby
 * @date: 2019/7/13 1:54
 */
public class TobyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        //创建一个bean定义对象
        RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(TobyBean.class);
        //把bean定义对象导入到容器中
        registry.registerBeanDefinition("tobyBean",rootBeanDefinition);
    }
}
